package models;

import java.sql.Date;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import play.db.DB;

public abstract class AdmCoral extends Usuario {

	public static List<Usuario> all() throws SQLException {
    	ResultSet rs = DB.executeQuery("SELECT * FROM usuario WHERE (tipo = 1 OR tipo = 2)");
    	
    	List<Usuario> lista = new ArrayList<Usuario>();
    	
    	while(rs.next()) {
    		AdmCoral admin;
    		if(rs.getInt(2) == 1) {
    			admin = new Secretario(rs.getInt(1), rs.getString(3), rs.getDate(4), 
        				rs.getInt(5), rs.getString(6), rs.getString(7), rs.getString(8),
        				rs.getString(9), rs.getString(10));
    		}
    		else {
    			admin = new Regente(rs.getInt(1), rs.getString(3), rs.getDate(4), 
        				rs.getInt(5), rs.getString(6), rs.getString(7), rs.getString(8),
        				rs.getString(9), rs.getString(10));
    		}
    		
    		lista.add(admin);
    	}
    	
    	return lista;
    }
}
